package com.hst.capacity.infra.persistence.jpa.order.intercity;

import com.hst.capacity.domain.model.entity.order.express.ExpressOrderSettlementEntity;
import com.hst.capacity.domain.model.entity.order.intercity.IntercityOrderSettlementEntity;
import com.hst.capacity.domain.model.response.express.ExOrderSettlementViewVO;
import com.hst.capacity.domain.model.response.intercity.IcOrderSettlementViewVO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

public interface IcOrderSettlementRepository extends JpaRepository<IntercityOrderSettlementEntity, String>, JpaSpecificationExecutor<IntercityOrderSettlementEntity> {

    /**
     * 根据订单ID查找订单结算表信息
     * @param idOrder
     * @return
     */
    IntercityOrderSettlementEntity findByIdOrder(String idOrder);

    @Query("select new com.hst.capacity.domain.model.response.intercity.IcOrderSettlementViewVO(v,s) from IntercityOrderSettlementEntity s left join IcOrderSettlementViewEntity v on s.idOrderSettlement = v.idOrderSettlement where v.idFranchisee=:idFranchisee")
    Page<IcOrderSettlementViewVO> findByIdFranchisee(String idFranchisee, PageRequest pageRequest);

}
